package jxc.servlet.info.customer;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jxc.data.hibernate.dao.CustomerDAO;
import jxc.data.hibernate.pojo.Customer;

/**
 * Servlet implementation class Detail
 */
@WebServlet("/info/customer/detail")
public class Detail extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id=request.getParameter("id");
		CustomerDAO dao=new CustomerDAO();
		Customer customer=dao.getById(id);
		if(customer==null){
			response.setCharacterEncoding("UTF-8");
			response.getWriter().print("找不到此客户");
			return;
		}
		request.setAttribute("c", customer);
		request.getRequestDispatcher("/info/customer/detail.jsp").forward(request, response);
	}


}
